package com.situ.project1.config;

import com.situ.project1.common.JwtInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebConfig implements WebMvcConfigurer {
    @Value("${jwt.secret.key}")
    private String jwtSecretKey;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JwtInterceptor(jwtSecretKey))
                .addPathPatterns("/api/**")
                .excludePathPatterns("/api/users/login/**")
                .excludePathPatterns("/api/users/logout/**")
                .excludePathPatterns("/api/users/captcha/**")
                .excludePathPatterns("/api/users/**")
                .excludePathPatterns("/api/car/rest/**")
                .excludePathPatterns("/api/employee/rest")
                .excludePathPatterns("/api/users/user-login/**")
                .excludePathPatterns("/api/customer/**")
                .excludePathPatterns("/api/customer/user-customer")
                .excludePathPatterns("/api/order/**")
                .excludePathPatterns("/api/car/restCar/**")
                .addPathPatterns("/api/loginCustomer/flag")
                .excludePathPatterns("/api/loginCustomer/user-login")
                .excludePathPatterns("/api/order/firstOrder");
    }
}
